package com.hongkl.service.impl;

import com.hongkl.entity.User;
import com.hongkl.mapper.UserMapper;
import com.hongkl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Integer getUser(User user) {
        // 数据库的操作
        if (user.getUsername().equals("zhangsan") && user.getPassword().equals("123456")){
            return 1;
        }


        return 0;
    }

    @Override
    public List<User> getAll() {

        // 获取用户的信息
        return userMapper.getAll();
    }

    @Override
    public User getUserInfo(String username) {
        return userMapper.getUserInfo(username);
    }

    @Override
    public Integer updateUserInfo(User user) {
        return userMapper.update(user);
    }

    @Override
    public Integer deleteUserInfo(Integer id) {
        return userMapper.deleteUser(id);
    }
}
